<!DOCTYPE html>












  


<html class="theme-next pisces use-motion" lang="zh-CN">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">


























<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2">

<link rel="stylesheet" href="/css/main.css?v=7.0.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/Peppa.png?v=7.0.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/Peppa.jpg?v=7.0.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/Peppa.jpg?v=7.0.0">








<script id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '7.0.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="CodeForces - 893 Educational Codeforces Round 33 1 A Chess For Three CodeForces - 893A1.1 题目大意A, B, C三个小伙伴玩象棋 象棋规则如下： 第一局A与B对弈，C观战 每一盘游戏结束后，输的小伙伴将观战，刚刚观战的小伙伴将与胜者继续对弈 他们共下了n盘象棋，并且记录下来了每一盘的胜者 请问记录是否有错（观">
<meta name="keywords" content="ACM,Tutorial,CodeForces">
<meta property="og:type" content="article">
<meta property="og:title" content="CodeForces - 893 Educational Codeforces Round 33">
<meta property="og:url" content="https://linxi99.gitee.io/20190214/CodeForces-893-Educational-Codeforces-Round-33/index.html">
<meta property="og:site_name" content="linxi&#39;s dream">
<meta property="og:description" content="CodeForces - 893 Educational Codeforces Round 33 1 A Chess For Three CodeForces - 893A1.1 题目大意A, B, C三个小伙伴玩象棋 象棋规则如下： 第一局A与B对弈，C观战 每一盘游戏结束后，输的小伙伴将观战，刚刚观战的小伙伴将与胜者继续对弈 他们共下了n盘象棋，并且记录下来了每一盘的胜者 请问记录是否有错（观">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2020-02-25T05:35:37.917Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="CodeForces - 893 Educational Codeforces Round 33">
<meta name="twitter:description" content="CodeForces - 893 Educational Codeforces Round 33 1 A Chess For Three CodeForces - 893A1.1 题目大意A, B, C三个小伙伴玩象棋 象棋规则如下： 第一局A与B对弈，C观战 每一盘游戏结束后，输的小伙伴将观战，刚刚观战的小伙伴将与胜者继续对弈 他们共下了n盘象棋，并且记录下来了每一盘的胜者 请问记录是否有错（观">






  <link rel="canonical" href="https://linxi99.gitee.io/20190214/CodeForces-893-Educational-Codeforces-Round-33/">



<script id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>CodeForces - 893 Educational Codeforces Round 33 | linxi's dream</title>
  






  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?b4099cd89c9f33abab06a03748dac801";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>







  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">linxi's dream</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <p class="site-subtitle">穷且益坚，不坠青云之志</p>
      
    
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">

    
    
    
      
    

    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">

    
    
    
      
    

    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">

    
    
    
      
    

    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">

    
    
    
      
    

    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>

      
      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
        </li>
      
    </ul>
  

  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://linxi99.gitee.io/20190214/CodeForces-893-Educational-Codeforces-Round-33/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="linxi">
      <meta itemprop="description" content="stay hungry, stay foolish">
      <meta itemprop="image" content="/images/star.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="linxi's dream">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">CodeForces - 893 Educational Codeforces Round 33

              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2019-02-14 23:16:21" itemprop="dateCreated datePublished" datetime="2019-02-14T23:16:21+08:00">2019-02-14</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2020-02-25 13:35:37" itemprop="dateModified" datetime="2020-02-25T13:35:37+08:00">2020-02-25</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/Contests/" itemprop="url" rel="index"><span itemprop="name">Contests</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <span class="post-meta-item-text">评论数：</span>
                <a href="/20190214/CodeForces-893-Educational-Codeforces-Round-33/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/20190214/CodeForces-893-Educational-Codeforces-Round-33/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
            <span id="/20190214/CodeForces-893-Educational-Codeforces-Round-33/" class="leancloud_visitors" data-flag-title="CodeForces - 893 Educational Codeforces Round 33">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              
                <span class="post-meta-item-text">阅读次数：</span>
              
                <span class="leancloud-visitors-count"></span>
            </span>
            <span class="post-meta-divider">|
            </span> <span title="post.wordcount">
            <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
            </span>字数： 5.1k
            </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>CodeForces - 893 Educational Codeforces Round 33</p>
<h1 id="1-A-Chess-For-Three-CodeForces-893A"><a href="#1-A-Chess-For-Three-CodeForces-893A" class="headerlink" title="1 A Chess For Three CodeForces - 893A"></a>1 A Chess For Three CodeForces - 893A</h1><h2 id="1-1-题目大意"><a href="#1-1-题目大意" class="headerlink" title="1.1 题目大意"></a>1.1 题目大意</h2><p>A, B, C三个小伙伴玩象棋</p>
<p>象棋规则如下：</p>
<p>第一局A与B对弈，C观战</p>
<p>每一盘游戏结束后，输的小伙伴将观战，刚刚观战的小伙伴将与胜者继续对弈</p>
<p>他们共下了n盘象棋，并且记录下来了每一盘的胜者</p>
<p>请问记录是否有错（观战的人胜利即为出错）</p>
<a id="more"></a>
<h2 id="1-2-解题思路"><a href="#1-2-解题思路" class="headerlink" title="1.2 解题思路"></a>1.2 解题思路</h2><p>用 spec[] 数组 记录一下当前小伙伴们的状态（true为观战，false为对弈）</p>
<p>依次判断是否出现观战者胜利即可</p>
<p>胜者状态不变，败者与观战者的状态取反</p>
<h2 id="1-3-代码实现"><a href="#1-3-代码实现" class="headerlink" title="1.3 代码实现"></a>1.3 代码实现</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdlib&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;set&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;map&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sd(n) scanf(<span class="meta-string">"%d"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sdd(n,m) scanf(<span class="meta-string">"%d%d"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sddd(n,m,k) scanf(<span class="meta-string">"%d%d%d"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pd(n) printf(<span class="meta-string">"%d\n"</span>, (n))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pdd(n,m) printf(<span class="meta-string">"%d %d"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pld(n) printf(<span class="meta-string">"%lld\n"</span>, n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pldd(n,m) printf(<span class="meta-string">"%lld %lld\n"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sld(n) scanf(<span class="meta-string">"%lld"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sldd(n,m) scanf(<span class="meta-string">"%lld%lld"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> slddd(n,m,k) scanf(<span class="meta-string">"%lld%lld%lld"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sf(n) scanf(<span class="meta-string">"%lf"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sff(n,m) scanf(<span class="meta-string">"%lf%lf"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sfff(n,m,k) scanf(<span class="meta-string">"%lf%lf%lf"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> ss(str) scanf(<span class="meta-string">"%s"</span>,str)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> rep(i,a,n) for (int i=a;i&lt;n;i++)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> per(i,a,n) for (int i=n-1;i&gt;=a;i--)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mm(a,n) memset(a, n, sizeof(a))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> debug(x) cout&lt;&lt;#x&lt;&lt;<span class="meta-string">": "</span>&lt;&lt;x&lt;&lt;endl</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pb push_back</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> all(x) (x).begin(),(x).end()</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> fi first</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> se second</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mp make_pair</span></span><br><span class="line"><span class="keyword">typedef</span> pair&lt;<span class="keyword">int</span>,<span class="keyword">int</span>&gt; PII;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> ll;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> ull;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">double</span> ld;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> mod = <span class="number">1e9</span> + <span class="number">7</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">double</span> eps = <span class="number">1e-9</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> maxn = <span class="number">3e5</span> + <span class="number">5</span>;</span><br><span class="line"><span class="comment">//head</span></span><br><span class="line"><span class="keyword">bool</span> spec[<span class="number">5</span>];</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="comment">//freopen("in.txt","r",stdin);</span></span><br><span class="line">	<span class="comment">//freopen("out.txt","w",stdout);</span></span><br><span class="line">    <span class="keyword">int</span> n; sd(n);</span><br><span class="line">    spec[<span class="number">3</span>] = <span class="literal">true</span>;</span><br><span class="line">    <span class="keyword">while</span>(n--)&#123;</span><br><span class="line">        <span class="keyword">int</span> x; sd(x);</span><br><span class="line">        <span class="keyword">if</span>(spec[x])&#123;</span><br><span class="line">            <span class="built_in">puts</span>(<span class="string">"NO"</span>);</span><br><span class="line">            <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= <span class="number">3</span>; ++i)&#123;</span><br><span class="line">            <span class="keyword">if</span>(i == x) <span class="keyword">continue</span>;</span><br><span class="line">            spec[i] = !spec[i];</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">puts</span>(<span class="string">"YES"</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="2-B-Beautiful-Divisors-CodeForces-893B"><a href="#2-B-Beautiful-Divisors-CodeForces-893B" class="headerlink" title="2 B - Beautiful Divisors CodeForces - 893B"></a>2 B - Beautiful Divisors CodeForces - 893B</h1><h2 id="2-1-题目大意"><a href="#2-1-题目大意" class="headerlink" title="2.1 题目大意"></a>2.1 题目大意</h2><p>在二进制表示中，前面有$x$个1后面有$x-1$个0的数我们之称为美丽数</p>
<p>题目提示：</p>
<p>More formally, the number is beautiful iff there exists some positive integer k such that the number is equal to $(2^k - 1) * (2^{k - 1})$.</p>
<p>给定一个n，问它的最大美丽数因子是多少</p>
<h2 id="2-2-解题思路"><a href="#2-2-解题思路" class="headerlink" title="2.2 解题思路"></a>2.2 解题思路</h2><p>根据题意我们知道，第一个美丽数是1，第二个是6</p>
<p>第$k$个美丽数满足$(2^k - 1) * (2^{k - 1})$</p>
<p>因此，小于n的美丽数不会超过$log_2 n$个</p>
<p>因此我们枚举美丽数判定即可</p>
<h2 id="2-3-代码实现"><a href="#2-3-代码实现" class="headerlink" title="2.3 代码实现"></a>2.3 代码实现</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdlib&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;set&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;map&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sd(n) scanf(<span class="meta-string">"%d"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sdd(n,m) scanf(<span class="meta-string">"%d%d"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sddd(n,m,k) scanf(<span class="meta-string">"%d%d%d"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pd(n) printf(<span class="meta-string">"%d\n"</span>, (n))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pdd(n,m) printf(<span class="meta-string">"%d %d"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pld(n) printf(<span class="meta-string">"%lld\n"</span>, n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pldd(n,m) printf(<span class="meta-string">"%lld %lld\n"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sld(n) scanf(<span class="meta-string">"%lld"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sldd(n,m) scanf(<span class="meta-string">"%lld%lld"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> slddd(n,m,k) scanf(<span class="meta-string">"%lld%lld%lld"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sf(n) scanf(<span class="meta-string">"%lf"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sff(n,m) scanf(<span class="meta-string">"%lf%lf"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sfff(n,m,k) scanf(<span class="meta-string">"%lf%lf%lf"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> ss(str) scanf(<span class="meta-string">"%s"</span>,str)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> rep(i,a,n) for (int i=a;i&lt;n;i++)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> per(i,a,n) for (int i=n-1;i&gt;=a;i--)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mm(a,n) memset(a, n, sizeof(a))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> debug(x) cout&lt;&lt;#x&lt;&lt;<span class="meta-string">": "</span>&lt;&lt;x&lt;&lt;endl</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pb push_back</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> all(x) (x).begin(),(x).end()</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> fi first</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> se second</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mp make_pair</span></span><br><span class="line"><span class="keyword">typedef</span> pair&lt;<span class="keyword">int</span>,<span class="keyword">int</span>&gt; PII;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> ll;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> ull;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">double</span> ld;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> mod = <span class="number">1e9</span> + <span class="number">7</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">double</span> eps = <span class="number">1e-9</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> maxn = <span class="number">3e5</span> + <span class="number">5</span>;</span><br><span class="line"><span class="comment">//head</span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">getbn</span><span class="params">(<span class="keyword">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="keyword">int</span> ret = <span class="number">1</span>&lt;&lt;(<span class="number">2</span>*x - <span class="number">1</span>);</span><br><span class="line">    ret -= <span class="number">1</span>&lt;&lt;(x - <span class="number">1</span>);</span><br><span class="line">    <span class="keyword">return</span> ret;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="comment">//freopen("in.txt","r",stdin);</span></span><br><span class="line">	<span class="comment">//freopen("out.txt","w",stdout);</span></span><br><span class="line">    <span class="keyword">int</span> n; sd(n);</span><br><span class="line">    <span class="keyword">int</span> ans = <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>; ; ++i)&#123;</span><br><span class="line">        <span class="keyword">int</span> x = getbn(i);</span><br><span class="line">        <span class="keyword">if</span>(x &gt; n) <span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">if</span>(n%x) <span class="keyword">continue</span>;</span><br><span class="line">        ans = x;</span><br><span class="line">    &#125;</span><br><span class="line">    pd(ans);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="3-C-Rumor-CodeForces-893C"><a href="#3-C-Rumor-CodeForces-893C" class="headerlink" title="3 C - Rumor CodeForces - 893C"></a>3 C - Rumor CodeForces - 893C</h1><h2 id="3-1-题目大意"><a href="#3-1-题目大意" class="headerlink" title="3.1 题目大意"></a>3.1 题目大意</h2><p>给定n个人</p>
<p>第$i$个人被贿赂需要$a_i$的代价</p>
<p>给定m个朋友关系</p>
<p>被贿赂的人会向他的朋友们免费传播谣言（当然，被贿赂的人已经算是被传播了谣言）</p>
<p>问这n个人都被传播谣言的最小代价是多少</p>
<h2 id="3-2-解题思路"><a href="#3-2-解题思路" class="headerlink" title="3.2 解题思路"></a>3.2 解题思路</h2><p>我们很容易知道</p>
<p>处于同一个朋友圈里的人，我们只需要贿赂这个朋友圈中所有人中代价最小的人</p>
<p>即可解决这个朋友圈</p>
<p>因此我们只需要并查集维护一下朋友圈以及朋友圈内的最小代价</p>
<p>然后枚举朋友圈，最小代价求和即是答案</p>
<h2 id="3-3-代码实现"><a href="#3-3-代码实现" class="headerlink" title="3.3 代码实现"></a>3.3 代码实现</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdlib&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;set&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;map&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sd(n) scanf(<span class="meta-string">"%d"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sdd(n,m) scanf(<span class="meta-string">"%d%d"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sddd(n,m,k) scanf(<span class="meta-string">"%d%d%d"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pd(n) printf(<span class="meta-string">"%d\n"</span>, (n))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pdd(n,m) printf(<span class="meta-string">"%d %d"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pld(n) printf(<span class="meta-string">"%lld\n"</span>, n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pldd(n,m) printf(<span class="meta-string">"%lld %lld\n"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sld(n) scanf(<span class="meta-string">"%lld"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sldd(n,m) scanf(<span class="meta-string">"%lld%lld"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> slddd(n,m,k) scanf(<span class="meta-string">"%lld%lld%lld"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sf(n) scanf(<span class="meta-string">"%lf"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sff(n,m) scanf(<span class="meta-string">"%lf%lf"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sfff(n,m,k) scanf(<span class="meta-string">"%lf%lf%lf"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> ss(str) scanf(<span class="meta-string">"%s"</span>,str)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> rep(i,a,n) for (int i=a;i&lt;n;i++)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> per(i,a,n) for (int i=n-1;i&gt;=a;i--)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mm(a,n) memset(a, n, sizeof(a))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> debug(x) cout&lt;&lt;#x&lt;&lt;<span class="meta-string">": "</span>&lt;&lt;x&lt;&lt;endl</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pb push_back</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> all(x) (x).begin(),(x).end()</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> fi first</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> se second</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mp make_pair</span></span><br><span class="line"><span class="keyword">typedef</span> pair&lt;<span class="keyword">int</span>,<span class="keyword">int</span>&gt; PII;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> ll;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> ull;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">double</span> ld;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> mod = <span class="number">1e9</span> + <span class="number">7</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">double</span> eps = <span class="number">1e-9</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> maxn = <span class="number">3e5</span> + <span class="number">5</span>;</span><br><span class="line"><span class="comment">//head</span></span><br><span class="line"><span class="keyword">int</span> fa[maxn];</span><br><span class="line">ll cost[maxn];</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">findfa</span><span class="params">(<span class="keyword">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="keyword">int</span> y = x;</span><br><span class="line">    <span class="keyword">while</span>(y != fa[y]) y = fa[y];</span><br><span class="line">    <span class="keyword">while</span>(x != fa[x])&#123;</span><br><span class="line">        <span class="keyword">int</span> z = fa[x];</span><br><span class="line">        fa[x] = y;</span><br><span class="line">        x = z;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> y;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="comment">//freopen("in.txt","r",stdin);</span></span><br><span class="line">	<span class="comment">//freopen("out.txt","w",stdout);</span></span><br><span class="line">    <span class="keyword">int</span> n, m; sdd(n, m); </span><br><span class="line">    rep(i, <span class="number">1</span>, n + <span class="number">1</span>)&#123;</span><br><span class="line">        sld(cost[i]);</span><br><span class="line">        fa[i] = i;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">while</span>(m--)&#123;</span><br><span class="line">        <span class="keyword">int</span> x, y; sdd(x, y);</span><br><span class="line">        <span class="keyword">int</span> fx = findfa(x), fy = findfa(y);</span><br><span class="line">        <span class="keyword">if</span>(fx == fy) <span class="keyword">continue</span>;</span><br><span class="line">        cost[fy] = min(cost[fx], cost[fy]);</span><br><span class="line">        fa[fx] = fy;</span><br><span class="line">    &#125;</span><br><span class="line">    ll ans = <span class="number">0</span>;</span><br><span class="line">    rep(i, <span class="number">1</span>, n + <span class="number">1</span>)&#123;</span><br><span class="line">        <span class="keyword">if</span>(fa[i] != i) <span class="keyword">continue</span>;</span><br><span class="line">        ans += cost[i];</span><br><span class="line">    &#125;</span><br><span class="line">    pld(ans);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="4-D-Credit-Card-CodeForces-893D"><a href="#4-D-Credit-Card-CodeForces-893D" class="headerlink" title="4 D - Credit Card CodeForces - 893D"></a>4 D - Credit Card CodeForces - 893D</h1><h2 id="4-1-题目大意"><a href="#4-1-题目大意" class="headerlink" title="4.1 题目大意"></a>4.1 题目大意</h2><p>给定天数n，以及信用卡里的最大钱数d</p>
<p>每天晚上银行将会有一个操作$a_i$</p>
<p>如果$a_i == 0$ ，今天晚上将进行检查，如果信用卡里的钱数小于0，则信用卡将会被注销</p>
<p>如果$a_i &gt; 0$，银行将在卡里充入$a_i$，否则将取走$a_i$</p>
<p>任何时刻卡里的钱数超过$d$元，信用卡将会被注销</p>
<p>你可以在每天早上去银行存钱（不可取钱）</p>
<p>问是否能够保证信用卡不被注销</p>
<p>可以的话，最少去银行存钱几次</p>
<h2 id="4-2-解题思路"><a href="#4-2-解题思路" class="headerlink" title="4.2 解题思路"></a>4.2 解题思路</h2><p>由于能够存钱，不能取钱</p>
<p>所以信用卡被注销，只有可能是因为信用卡里的钱超过了d元</p>
<p>因为在银行检查的当天，如果钱数小于零，在早上一定可以存钱使得其大于零</p>
<p>为了保证取得次数最少</p>
<p>我们在必须存钱时，一定是在保证在后续操作的钱数不超过d的情况下，存的越多越好</p>
<p>因此，我们只需要记录一下，在信用卡不被注销的情况下</p>
<p>当前可能的最大钱数是多少，当前可能的最小钱数是多少</p>
<p>当银行检查余额时</p>
<p>当前可能最小钱数如果小于零，则将置为0</p>
<p>当前可能最大钱数如果小于零则说明，我们必须进行一次存钱了，所以更新答案，将最大可能钱数置为 d</p>
<p>当银行进行存取钱操作时，更新最大最小钱数</p>
<p>如果最大钱数大于 d，则将其置回 d，保证满足题意</p>
<p>当当前可能的最小钱数大于d时，则信用卡一定会被注销</p>
<h2 id="4-3-代码实现"><a href="#4-3-代码实现" class="headerlink" title="4.3 代码实现"></a>4.3 代码实现</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdlib&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;set&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;map&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sd(n) scanf(<span class="meta-string">"%d"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sdd(n,m) scanf(<span class="meta-string">"%d%d"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sddd(n,m,k) scanf(<span class="meta-string">"%d%d%d"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pd(n) printf(<span class="meta-string">"%d\n"</span>, (n))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pdd(n,m) printf(<span class="meta-string">"%d %d"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pld(n) printf(<span class="meta-string">"%lld\n"</span>, n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pldd(n,m) printf(<span class="meta-string">"%lld %lld\n"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sld(n) scanf(<span class="meta-string">"%lld"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sldd(n,m) scanf(<span class="meta-string">"%lld%lld"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> slddd(n,m,k) scanf(<span class="meta-string">"%lld%lld%lld"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sf(n) scanf(<span class="meta-string">"%lf"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sff(n,m) scanf(<span class="meta-string">"%lf%lf"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sfff(n,m,k) scanf(<span class="meta-string">"%lf%lf%lf"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> ss(str) scanf(<span class="meta-string">"%s"</span>,str)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> rep(i,a,n) for (int i=a;i&lt;n;i++)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> per(i,a,n) for (int i=n-1;i&gt;=a;i--)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mm(a,n) memset(a, n, sizeof(a))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> debug(x) cout&lt;&lt;#x&lt;&lt;<span class="meta-string">": "</span>&lt;&lt;x&lt;&lt;endl</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pb push_back</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> all(x) (x).begin(),(x).end()</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> fi first</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> se second</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mp make_pair</span></span><br><span class="line"><span class="keyword">typedef</span> pair&lt;<span class="keyword">int</span>,<span class="keyword">int</span>&gt; PII;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> ll;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> ull;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">double</span> ld;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> mod = <span class="number">1e9</span> + <span class="number">7</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">double</span> eps = <span class="number">1e-9</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> maxn = <span class="number">3e5</span> + <span class="number">5</span>;</span><br><span class="line"><span class="comment">//head</span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="comment">//freopen("in.txt","r",stdin);</span></span><br><span class="line">	<span class="comment">//freopen("out.txt","w",stdout);</span></span><br><span class="line">    <span class="keyword">int</span> n, d; sdd(n, d);</span><br><span class="line">    <span class="keyword">bool</span> ok = <span class="literal">true</span>;</span><br><span class="line">    <span class="keyword">int</span> mx = <span class="number">0</span>, mi = <span class="number">0</span>, ans = <span class="number">0</span>;</span><br><span class="line">    rep(i, <span class="number">0</span>, n)&#123;</span><br><span class="line">        <span class="keyword">int</span> x; sd(x);</span><br><span class="line">        <span class="keyword">if</span>(!ok) <span class="keyword">continue</span>;</span><br><span class="line">        <span class="keyword">if</span>(x == <span class="number">0</span>)&#123;</span><br><span class="line">            <span class="keyword">if</span>(mx &lt; <span class="number">0</span>)&#123;</span><br><span class="line">                mx = d;</span><br><span class="line">                ++ans;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(mi &lt; <span class="number">0</span>) mi = <span class="number">0</span>;</span><br><span class="line">            <span class="keyword">continue</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        mx += x, mi += x;</span><br><span class="line">        <span class="keyword">if</span>(x &gt; <span class="number">0</span>)&#123;</span><br><span class="line">            <span class="keyword">if</span>(mx &gt; d) mx = d;</span><br><span class="line">            <span class="keyword">if</span>(mi &gt; d) ok = <span class="literal">false</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span>(!ok) ans = <span class="number">-1</span>;</span><br><span class="line">    pd(ans);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="5-E-Counting-Arrays-CodeForces-893E"><a href="#5-E-Counting-Arrays-CodeForces-893E" class="headerlink" title="5 E - Counting Arrays CodeForces - 893E"></a>5 E - Counting Arrays CodeForces - 893E</h1><h2 id="5-1-题目大意"><a href="#5-1-题目大意" class="headerlink" title="5.1 题目大意"></a>5.1 题目大意</h2><p>q次询问</p>
<p>每次询问给定一个$x_i$和$y_i$</p>
<p>$y_i$个数的乘积为$x_i$的情况下，共用多少种排列情况</p>
<h2 id="5-2-解题思路"><a href="#5-2-解题思路" class="headerlink" title="5.2 解题思路"></a>5.2 解题思路</h2><p>我们将 $x$ 进行质因子分解</p>
<p>获得这样一种形式</p>
<script type="math/tex; mode=display">x = p_1^{n_1} p_2^{n_2} \cdots p_x ^{n_x}</script><p>这样的话，我们只需要考虑将每个特定的质因子分配给这$y$个数，一共有多少种情况</p>
<p>如果只能分配为正数时，总方案数将是这些质因子的方案数的乘积</p>
<p>加入某个质因子，它分解出来的个数是$cnt$个，将它们分配给$y$个数（允许分配零个）会有多少种情况呢</p>
<p>这样的话，相当于把$cnt$个球分配到$y$个桶里，允许空桶</p>
<p>使用隔板法的话，是不允许两个隔板之间的球的个数为零的</p>
<p>我们可以假设存在$cnt + y$个球，这样便可以使用隔板法后，每个桶里的球的个数 是 隔板间球的个数减一</p>
<p>即满足桶里球的个数可以为零，又满足使用隔板法的条件</p>
<p>这样的话，我们进行隔板法计算它的组合数将是</p>
<script type="math/tex; mode=display">C_{cnt + y - 1} ^ {y - 1}</script><p>由于需要取模，所以需要预处理出来所有阶乘逆元</p>
<p>考虑负数的情况，由于给定的$x &gt; 0$所以负数的个数将是偶数个</p>
<script type="math/tex; mode=display">tot = C_y^0 + C_y^2 + \cdots</script><p>根据组合数的性质，所有奇数项的和等于所有偶数项的和，等于$tot = 2^{y - 1}$</p>
<p>因此最后的方案数需要乘上$tot$</p>
<p>由于直接暴力判定质因子，时间会超</p>
<p>所以我们考虑只枚举小于$sqrt(x)$的质因子</p>
<p>如果最后$x &gt; 1$则说明x为一个素数</p>
<p>只需要乘上一个$C_y^1$也就是$y$即可</p>
<h2 id="5-3-代码实现"><a href="#5-3-代码实现" class="headerlink" title="5.3 代码实现"></a>5.3 代码实现</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdlib&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;set&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;map&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sd(n) scanf(<span class="meta-string">"%d"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sdd(n,m) scanf(<span class="meta-string">"%d%d"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sddd(n,m,k) scanf(<span class="meta-string">"%d%d%d"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pd(n) printf(<span class="meta-string">"%d\n"</span>, (n))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pdd(n,m) printf(<span class="meta-string">"%d %d"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pld(n) printf(<span class="meta-string">"%lld\n"</span>, n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pldd(n,m) printf(<span class="meta-string">"%lld %lld\n"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sld(n) scanf(<span class="meta-string">"%lld"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sldd(n,m) scanf(<span class="meta-string">"%lld%lld"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> slddd(n,m,k) scanf(<span class="meta-string">"%lld%lld%lld"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sf(n) scanf(<span class="meta-string">"%lf"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sff(n,m) scanf(<span class="meta-string">"%lf%lf"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sfff(n,m,k) scanf(<span class="meta-string">"%lf%lf%lf"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> ss(str) scanf(<span class="meta-string">"%s"</span>,str)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> rep(i,a,n) for (int i=a;i&lt;n;i++)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> per(i,a,n) for (int i=n-1;i&gt;=a;i--)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mm(a,n) memset(a, n, sizeof(a))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> debug(x) cout&lt;&lt;#x&lt;&lt;<span class="meta-string">": "</span>&lt;&lt;x&lt;&lt;endl</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pb push_back</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> all(x) (x).begin(),(x).end()</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> fi first</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> se second</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mp make_pair</span></span><br><span class="line"><span class="keyword">typedef</span> pair&lt;<span class="keyword">int</span>,<span class="keyword">int</span>&gt; PII;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> ll;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> ull;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">double</span> ld;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> mod = <span class="number">1e9</span> + <span class="number">7</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">double</span> eps = <span class="number">1e-9</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> maxn = <span class="number">3e5</span> + <span class="number">5</span>;</span><br><span class="line"><span class="comment">//head</span></span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> mx = <span class="number">3e6</span> + <span class="number">5</span>;</span><br><span class="line">ll fac[mx], inv_fac[mx];</span><br><span class="line"><span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt; p;</span><br><span class="line"><span class="keyword">bool</span> np[mx];</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">getP</span><span class="params">()</span></span>&#123;</span><br><span class="line">    np[<span class="number">1</span>] = <span class="literal">true</span>;</span><br><span class="line">    <span class="keyword">int</span> sx = <span class="built_in">sqrt</span>(mx);</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">2</span>; i &lt; sx; ++i)&#123;</span><br><span class="line">        <span class="keyword">if</span>(!np[i]) p.pb(i);</span><br><span class="line">        <span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">0</span>; j &lt; p.size(); ++j)&#123;</span><br><span class="line">            <span class="keyword">int</span> num = i*p[j];</span><br><span class="line">            <span class="keyword">if</span>(num &gt;= sx) <span class="keyword">break</span>;</span><br><span class="line">            np[num] = <span class="literal">true</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function">ll <span class="title">pow_m</span><span class="params">(ll a, ll b, ll mod)</span></span>&#123;</span><br><span class="line">    ll ret = <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">while</span>(b)&#123;</span><br><span class="line">        <span class="keyword">if</span>(b&amp;<span class="number">1</span>) ret = (ret*a)%mod;</span><br><span class="line">        a = (a*a)%mod;</span><br><span class="line">        b &gt;&gt;= <span class="number">1</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> ret;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">getFac</span><span class="params">()</span></span>&#123;</span><br><span class="line">    fac[<span class="number">0</span>] = <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>; i &lt; mx; ++i) fac[i] = (fac[i - <span class="number">1</span>]*i)%mod;</span><br><span class="line">    inv_fac[mx - <span class="number">1</span>] = pow_m(fac[mx - <span class="number">1</span>], mod - <span class="number">2</span>, mod);</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i = mx - <span class="number">2</span>; i &gt;= <span class="number">0</span>; --i) inv_fac[i] = (inv_fac[i + <span class="number">1</span>]*(i + <span class="number">1</span>))%mod;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="comment">//freopen("in.txt","r",stdin);</span></span><br><span class="line">	<span class="comment">//freopen("out.txt","w",stdout);</span></span><br><span class="line">    getFac();</span><br><span class="line">    getP();</span><br><span class="line">    <span class="keyword">int</span> q; sd(q);</span><br><span class="line">    <span class="keyword">int</span> num = (<span class="keyword">int</span>)p.size();</span><br><span class="line">    <span class="keyword">while</span>(q--)&#123;</span><br><span class="line">        <span class="keyword">int</span> x, y; sdd(x, y);</span><br><span class="line">        ll ans = <span class="number">1</span>;</span><br><span class="line">        rep(i, <span class="number">0</span>, num)&#123;</span><br><span class="line">            <span class="keyword">if</span>(x == <span class="number">1</span>) <span class="keyword">break</span>;</span><br><span class="line">            ll cnt = <span class="number">0</span>;</span><br><span class="line">            <span class="keyword">while</span>(x%p[i] == <span class="number">0</span>)&#123;</span><br><span class="line">                ++cnt;</span><br><span class="line">                x /= p[i];</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(cnt)&#123;</span><br><span class="line">                ll val = fac[cnt + y - <span class="number">1</span>];</span><br><span class="line">                val = (val*inv_fac[y - <span class="number">1</span>])%mod;</span><br><span class="line">                val = (val*inv_fac[cnt])%mod;</span><br><span class="line">                ans = (ans*val)%mod;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span>(x &gt; <span class="number">1</span>) ans = (ans*(ll)y)%mod;</span><br><span class="line">        ll val = pow_m(<span class="number">2L</span>L, y - <span class="number">1</span>, mod);</span><br><span class="line">        ans = (ans*val)%mod;</span><br><span class="line">        pld(ans);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">*/</span></span><br></pre></td></tr></table></figure>
<h1 id="6-F-Subtree-Minimum-Query-CodeForces-893F"><a href="#6-F-Subtree-Minimum-Query-CodeForces-893F" class="headerlink" title="6 F - Subtree Minimum Query CodeForces - 893F"></a>6 F - Subtree Minimum Query CodeForces - 893F</h1><h2 id="6-1-题目大意"><a href="#6-1-题目大意" class="headerlink" title="6.1 题目大意"></a>6.1 题目大意</h2><p>给定一棵n个节点以r为根的树，每个节点有一个权值 $a_i$</p>
<p>进行m次询问，每次询问以 x 为根节点， 距离不大于 k 的所有节点中，最小的权值是多少</p>
<p>询问强制在线（根据上次的答案解密下一次询问的 x 与 k）</p>
<h2 id="6-2-解题思路"><a href="#6-2-解题思路" class="headerlink" title="6.2 解题思路"></a>6.2 解题思路</h2><p>最多$10^5$个节点，$10^6$次询问，我们考虑使用线段树</p>
<p>由于有询问子树的需求，我们很容易想到获得这棵树的以r为根dfs序</p>
<p>在树的dfs序中，一棵树的子树部分，将会是连续的一个序列</p>
<p>因此我们便可以通过线段树来维护一些东西，搞一些事情</p>
<p>在重新审视题意，我们可以发现，假定dfs序列中以 x 为根的连续子序列是 $[lf, rt]$</p>
<p>要求距离 x 不超过 k, 因此在原树中，这些满足条件的节点深度在区间 $[d[x], d[x] + k]$ 中</p>
<p>因此我们所求的问题便转化为了，在二维坐标系中，在某个矩形区域内部点的最小权值</p>
<p>由于我们所求的最小值，没有可加减的性质，因此无法通过二维前缀和解决</p>
<p>这种情况下的解决办法有 kd树，树套树 等我还不会写的的神仙数据结构</p>
<p>因此我们继续审视题目，我们可以发现，在所给定的条件中</p>
<p>如果确定节点深度所在的区间，我们发现，它们的dfs序并没有什么特殊的性质</p>
<p>如果我们确定dfs序所在区间，我们可以发现，它们的深度一定大于$d[x]$（因为是以$x$为根节点的子树）</p>
<p>因此我们可以发现在深度 $[1, d[x])$ 中，没有任何节点处于其中</p>
<p>因此我们可以放心的将原问题转化为</p>
<p>在dfs序处于[lf, rt]，并且相对于原数深度不大于$d[x] + k$的节点中，最小权值是多少</p>
<p>我们发现在深度这个维度</p>
<p>我们不再需要截断某一段去查询（因为可以直接查询小于等于$d[x] + k$）的所有节点</p>
<p>这样的话，我们便不需要在考虑最小值无法加减截断的事情</p>
<p>因此我们便只需要以dfs序建一棵线段树，以深度（从小到大）为时间线推进维护起来即可</p>
<p>即，我们需要建一棵，以dfs序为基，以节点深度为时间轴的主席树（留坑，以后补一篇博客）即可</p>
<h2 id="6-3-代码实现"><a href="#6-3-代码实现" class="headerlink" title="6.3 代码实现"></a>6.3 代码实现</h2><p>1341ms 48700kB</p>
<p>主席树真好写 <del>才花了3个小时就写完了</del></p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdlib&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;set&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;map&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sd(n) scanf(<span class="meta-string">"%d"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sdd(n,m) scanf(<span class="meta-string">"%d%d"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sddd(n,m,k) scanf(<span class="meta-string">"%d%d%d"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pd(n) printf(<span class="meta-string">"%d\n"</span>, (n))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pdd(n,m) printf(<span class="meta-string">"%d %d"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pld(n) printf(<span class="meta-string">"%lld\n"</span>, n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pldd(n,m) printf(<span class="meta-string">"%lld %lld\n"</span>, n, m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sld(n) scanf(<span class="meta-string">"%lld"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sldd(n,m) scanf(<span class="meta-string">"%lld%lld"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> slddd(n,m,k) scanf(<span class="meta-string">"%lld%lld%lld"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sf(n) scanf(<span class="meta-string">"%lf"</span>,&amp;n)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sff(n,m) scanf(<span class="meta-string">"%lf%lf"</span>,&amp;n,&amp;m)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> sfff(n,m,k) scanf(<span class="meta-string">"%lf%lf%lf"</span>,&amp;n,&amp;m,&amp;k)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> ss(str) scanf(<span class="meta-string">"%s"</span>,str)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> rep(i,a,n) for (int i=a;i&lt;n;i++)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> per(i,a,n) for (int i=n-1;i&gt;=a;i--)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mm(a,n) memset(a, n, sizeof(a))</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> debug(x) cout&lt;&lt;#x&lt;&lt;<span class="meta-string">": "</span>&lt;&lt;x&lt;&lt;endl</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> pb push_back</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> all(x) (x).begin(),(x).end()</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> fi first</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> se second</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> mp make_pair</span></span><br><span class="line"><span class="keyword">typedef</span> pair&lt;<span class="keyword">int</span>,<span class="keyword">int</span>&gt; PII;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">long</span> ll;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> ull;</span><br><span class="line"><span class="keyword">typedef</span> <span class="keyword">long</span> <span class="keyword">double</span> ld;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> mod = <span class="number">1e9</span> + <span class="number">7</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">double</span> eps = <span class="number">1e-9</span>;</span><br><span class="line"><span class="comment">//head</span></span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> maxn = <span class="number">1e5</span> + <span class="number">5</span>;</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">node</span>&#123;</span></span><br><span class="line">    <span class="keyword">int</span> l, r;</span><br><span class="line">    <span class="keyword">int</span> mi;</span><br><span class="line">&#125;T[maxn&lt;&lt;<span class="number">5</span>];</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">num</span>&#123;</span></span><br><span class="line">    <span class="keyword">int</span> id;</span><br><span class="line">    <span class="keyword">int</span> x, d;</span><br><span class="line">    <span class="keyword">int</span> lf, rt;</span><br><span class="line">    <span class="keyword">bool</span> <span class="keyword">operator</span> &lt;(<span class="keyword">const</span> num&amp; n) <span class="keyword">const</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> d &lt; n.d;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;a[maxn];</span><br><span class="line"><span class="keyword">int</span> root[maxn], lst[maxn], cnt = <span class="number">0</span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">build</span><span class="params">(<span class="keyword">int</span>&amp; x, <span class="keyword">int</span> l, <span class="keyword">int</span> r)</span></span>&#123;</span><br><span class="line">    x = <span class="number">0</span>; T[x].mi = <span class="number">0x3f3f3f3f</span>;</span><br><span class="line">    <span class="keyword">if</span>(l == r) <span class="keyword">return</span> ;</span><br><span class="line">    <span class="keyword">int</span> mid = (l + r)&gt;&gt;<span class="number">1</span>;</span><br><span class="line">    build(T[x].l, l, mid);</span><br><span class="line">    build(T[x].r, mid + <span class="number">1</span>, r);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">update</span><span class="params">(<span class="keyword">int</span> l, <span class="keyword">int</span> r, <span class="keyword">int</span>&amp; x, <span class="keyword">int</span> y, <span class="keyword">int</span> pos, <span class="keyword">int</span> val)</span></span>&#123;</span><br><span class="line">    T[++cnt] = T[y]; x = cnt;</span><br><span class="line">    <span class="keyword">if</span>(l == r)&#123;</span><br><span class="line">        T[x].mi = val;</span><br><span class="line">        <span class="keyword">return</span> ;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">int</span> mid = (l + r)&gt;&gt;<span class="number">1</span>;</span><br><span class="line">    <span class="keyword">if</span>(mid &gt;= pos) update(l, mid, T[x].l, T[y].l, pos, val);</span><br><span class="line">    <span class="keyword">else</span> update(mid + <span class="number">1</span>, r, T[x].r, T[y].r, pos, val);</span><br><span class="line">    T[x].mi = min(T[T[x].l].mi, T[T[x].r].mi);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">query</span><span class="params">(<span class="keyword">int</span> l, <span class="keyword">int</span> r, <span class="keyword">int</span> x, <span class="keyword">int</span> lf, <span class="keyword">int</span> rt)</span></span>&#123;</span><br><span class="line">    <span class="keyword">int</span> mid = (l + r)&gt;&gt;<span class="number">1</span>, ret = <span class="number">0x3f3f3f3f</span>;</span><br><span class="line">    <span class="keyword">if</span>(lf &lt;= l &amp;&amp;  rt &gt;= r) <span class="keyword">return</span> T[x].mi;</span><br><span class="line">    <span class="keyword">if</span>(lf &lt;= mid) ret = min(ret, query(l, mid, T[x].l, lf, rt));</span><br><span class="line">    <span class="keyword">if</span>(rt &gt; mid) ret = min(ret, query(mid + <span class="number">1</span>, r, T[x].r, lf, rt));</span><br><span class="line">    <span class="keyword">return</span> ret;</span><br><span class="line">&#125;</span><br><span class="line"><span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt; g[maxn];</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">addedge</span><span class="params">(<span class="keyword">int</span> u, <span class="keyword">int</span> v)</span></span>&#123;</span><br><span class="line">    g[u].pb(v);</span><br><span class="line">    g[v].pb(u);</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">int</span> mx = <span class="number">0</span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> now, <span class="keyword">int</span> lst)</span></span>&#123;</span><br><span class="line">    <span class="keyword">if</span>(mx &lt; a[now].d) mx = a[now].d; </span><br><span class="line">    <span class="keyword">int</span> sz = g[now].size();</span><br><span class="line">    a[now].lf = ++cnt;</span><br><span class="line">    rep(i, <span class="number">0</span>, sz)&#123;</span><br><span class="line">        <span class="keyword">int</span> to = g[now][i];</span><br><span class="line">        <span class="keyword">if</span>(lst == to) <span class="keyword">continue</span>;</span><br><span class="line">        a[to].d = a[now].d + <span class="number">1</span>; dfs(to, now);</span><br><span class="line">    &#125;</span><br><span class="line">    a[now].rt = cnt;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">bool</span> <span class="title">cmp</span><span class="params">(num a, num b)</span></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> a.id &lt; b.id;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="comment">//freopen("in.txt","r",stdin);</span></span><br><span class="line">	<span class="comment">//freopen("out.txt","w",stdout);</span></span><br><span class="line">    <span class="keyword">int</span> n, r; sdd(n, r);</span><br><span class="line">    rep(i, <span class="number">1</span>, n + <span class="number">1</span>)&#123;</span><br><span class="line">        sd(a[i].x);</span><br><span class="line">        a[i].id = i; </span><br><span class="line">    &#125;</span><br><span class="line">    build(root[<span class="number">0</span>], <span class="number">1</span>, n);</span><br><span class="line">    rep(i, <span class="number">1</span>, n)&#123;</span><br><span class="line">        <span class="keyword">int</span> x, y; sdd(x, y);</span><br><span class="line">        addedge(x, y);</span><br><span class="line">    &#125;</span><br><span class="line"><span class="comment">//    puts("");</span></span><br><span class="line">    a[r].d = <span class="number">1</span>; dfs(r, <span class="number">-1</span>);</span><br><span class="line"><span class="comment">//    rep(i, 0, n)&#123;</span></span><br><span class="line"><span class="comment">//        printf("%d %d %d", i, a[i].lf, a[i].rt);</span></span><br><span class="line"><span class="comment">//        printf(" %d\n", a[i].d);</span></span><br><span class="line"><span class="comment">//    &#125;</span></span><br><span class="line">    sort(a + <span class="number">1</span>, a + n + <span class="number">1</span>);</span><br><span class="line">    rep(i, <span class="number">1</span>, n + <span class="number">1</span>) update(<span class="number">1</span>, n, root[i], root[i - <span class="number">1</span>], a[i].lf, a[i].x);</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= n; ++i)&#123;</span><br><span class="line">        <span class="keyword">int</span> pos = i;</span><br><span class="line">        <span class="keyword">while</span>(pos &lt; n)&#123;</span><br><span class="line">            <span class="keyword">if</span>(a[i].d != a[pos + <span class="number">1</span>].d) <span class="keyword">break</span>;</span><br><span class="line">            ++pos;</span><br><span class="line">        &#125;</span><br><span class="line">        lst[a[i].d] = pos;</span><br><span class="line">        i = pos;</span><br><span class="line">    &#125;</span><br><span class="line">    sort(a + <span class="number">1</span>, a + n + <span class="number">1</span>, cmp);</span><br><span class="line">    <span class="keyword">int</span> ans = <span class="number">0</span>, m; sd(m);</span><br><span class="line">    <span class="keyword">while</span>(m--)&#123;</span><br><span class="line">        <span class="keyword">int</span> p, q; sdd(p, q);</span><br><span class="line">        p = (ans + p)%n + <span class="number">1</span>, q = (ans + q)%n;</span><br><span class="line">        <span class="keyword">int</span> dd = min(mx, a[p].d + q);</span><br><span class="line">        ans = query(<span class="number">1</span>, n, root[lst[dd]], a[p].lf, a[p].rt);</span><br><span class="line">        pd(ans);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/ACM/" rel="tag"># ACM</a>
          
            <a href="/tags/Tutorial/" rel="tag"># Tutorial</a>
          
            <a href="/tags/CodeForces/" rel="tag"># CodeForces</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/20190211/ACM计算几何篇/" rel="next" title="ACM计算几何篇">
                <i class="fa fa-chevron-left"></i> ACM计算几何篇
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/20190217/Cayley-s-formula-And-Prufer-sequences/" rel="prev" title="Cayley's formula And Prüfer sequences">
                Cayley's formula And Prüfer sequences <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  
    <div class="comments" id="comments">
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/star.jpg" alt="linxi">
            
              <p class="site-author-name" itemprop="name">linxi</p>
              <p class="site-description motion-element" itemprop="description">stay hungry, stay foolish</p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">15</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">9</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">13</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          

          

          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                Links
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="https://blog.csdn.net/linxilinxilinxi" title="https://blog.csdn.net/linxilinxilinxi" rel="noopener" target="_blank">My CSDN</a>
                  </li>
                
              </ul>
            </div>
          

          
            
          
          

        </div>
      </div>

      
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#1-A-Chess-For-Three-CodeForces-893A"><span class="nav-number">1.</span> <span class="nav-text">1 A Chess For Three CodeForces - 893A</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-1-题目大意"><span class="nav-number">1.1.</span> <span class="nav-text">1.1 题目大意</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#1-2-解题思路"><span class="nav-number">1.2.</span> <span class="nav-text">1.2 解题思路</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#1-3-代码实现"><span class="nav-number">1.3.</span> <span class="nav-text">1.3 代码实现</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#2-B-Beautiful-Divisors-CodeForces-893B"><span class="nav-number">2.</span> <span class="nav-text">2 B - Beautiful Divisors CodeForces - 893B</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#2-1-题目大意"><span class="nav-number">2.1.</span> <span class="nav-text">2.1 题目大意</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-2-解题思路"><span class="nav-number">2.2.</span> <span class="nav-text">2.2 解题思路</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-3-代码实现"><span class="nav-number">2.3.</span> <span class="nav-text">2.3 代码实现</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#3-C-Rumor-CodeForces-893C"><span class="nav-number">3.</span> <span class="nav-text">3 C - Rumor CodeForces - 893C</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#3-1-题目大意"><span class="nav-number">3.1.</span> <span class="nav-text">3.1 题目大意</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-2-解题思路"><span class="nav-number">3.2.</span> <span class="nav-text">3.2 解题思路</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-3-代码实现"><span class="nav-number">3.3.</span> <span class="nav-text">3.3 代码实现</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#4-D-Credit-Card-CodeForces-893D"><span class="nav-number">4.</span> <span class="nav-text">4 D - Credit Card CodeForces - 893D</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#4-1-题目大意"><span class="nav-number">4.1.</span> <span class="nav-text">4.1 题目大意</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-2-解题思路"><span class="nav-number">4.2.</span> <span class="nav-text">4.2 解题思路</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-3-代码实现"><span class="nav-number">4.3.</span> <span class="nav-text">4.3 代码实现</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#5-E-Counting-Arrays-CodeForces-893E"><span class="nav-number">5.</span> <span class="nav-text">5 E - Counting Arrays CodeForces - 893E</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#5-1-题目大意"><span class="nav-number">5.1.</span> <span class="nav-text">5.1 题目大意</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-2-解题思路"><span class="nav-number">5.2.</span> <span class="nav-text">5.2 解题思路</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-3-代码实现"><span class="nav-number">5.3.</span> <span class="nav-text">5.3 代码实现</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#6-F-Subtree-Minimum-Query-CodeForces-893F"><span class="nav-number">6.</span> <span class="nav-text">6 F - Subtree Minimum Query CodeForces - 893F</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#6-1-题目大意"><span class="nav-number">6.1.</span> <span class="nav-text">6.1 题目大意</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-2-解题思路"><span class="nav-number">6.2.</span> <span class="nav-text">6.2 解题思路</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-3-代码实现"><span class="nav-number">6.3.</span> <span class="nav-text">6.3 代码实现</span></a></li></ol></li></ol></div>
            

          </div>
        </div>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2019 – <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">linxi</span>

  

  
</div>


  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.8.0</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> v7.0.0</div>





<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">全站共 65.5k 字</span>
</div>

        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

    

    
  </div>

  

<script>
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>














  
    
    
  
  <script color="25,202,173" opacity="0.8" zindex="-1" count="200" src="/lib/canvas-nest/canvas-nest.min.js"></script>













  
  <script src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>


  


  <script src="/js/src/utils.js?v=7.0.0"></script>

  <script src="/js/src/motion.js?v=7.0.0"></script>



  
  


  <script src="/js/src/affix.js?v=7.0.0"></script>

  <script src="/js/src/schemes/pisces.js?v=7.0.0"></script>



  
  <script src="/js/src/scrollspy.js?v=7.0.0"></script>
<script src="/js/src/post-details.js?v=7.0.0"></script>



  


  <script src="/js/src/bootstrap.js?v=7.0.0"></script>



  
  

<script src="//cdn1.lncld.net/static/js/3.11.1/av-min.js"></script>



<script src="//unpkg.com/valine/dist/Valine.min.js"></script>

<script>
  var GUEST = ['nick', 'mail', 'link'];
  var guest = 'nick,mail,link';
  guest = guest.split(',').filter(function(item) {
    return GUEST.indexOf(item) > -1;
  });
  new Valine({
    el: '#comments',
    verify: false,
    notify: false,
    appId: 'LwzdQrGG81bUwkUkAfdPexj1-gzGzoHsz',
    appKey: 'akTaTqH7XeeKc6CPRfB7vbDl',
    placeholder: 'Just go go',
    avatar: 'mm',
    meta: guest,
    pageSize: '10' || 10,
    visitor: false
  });
</script>




  


  
  <script>
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url).replace(/\/{2,}/g, '/');
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x"></i></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x"></i></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  
  
  <script>
    
    function addCount(Counter) {
      var $visitors = $('.leancloud_visitors');
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();

      Counter('get', '/classes/Counter', { where: JSON.stringify({ url }) })
        .done(function({ results }) {
          if (results.length > 0) {
            var counter = results[0];
            
            Counter('put', '/classes/Counter/' + counter.objectId, JSON.stringify({ time: { '__op': 'Increment', 'amount': 1 } }))
            
              .done(function() {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.time + 1);
              })
            
              .fail(function ({ responseJSON }) {
                console.log(`Failed to save Visitor num, with error message: ${responseJSON.error}`);
              })
          } else {
            
              Counter('post', '/classes/Counter', JSON.stringify({ title: title, url: url, time: 1 }))
                .done(function() {
                  var $element = $(document.getElementById(url));
                  $element.find('.leancloud-visitors-count').text(1);
                })
                .fail(function() {
                  console.log('Failed to create');
                });
            
          }
        })
        .fail(function ({ responseJSON }) {
          console.log(`LeanCloud Counter Error: ${responseJSON.code} ${responseJSON.error}`);
        });
    }
    

    $(function() {
      $.get('https://app-router.leancloud.cn/2/route?appId=' + 'LwzdQrGG81bUwkUkAfdPexj1-gzGzoHsz')
        .done(function({ api_server }) {
          var Counter = function(method, url, data) {
            return $.ajax({
              method: method,
              url: 'https://' + api_server + '/1.1' + url,
              headers: {
                'X-LC-Id': 'LwzdQrGG81bUwkUkAfdPexj1-gzGzoHsz',
                'X-LC-Key': 'akTaTqH7XeeKc6CPRfB7vbDl',
                'Content-Type': 'application/json',
              },
              data: data
            });
          };
          
            addCount(Counter);
          
        });
    });
  </script>



  

  
  

  
  

  
    
      <script type="text/x-mathjax-config">
  

  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true,
      skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    },
    TeX: {
      
      equationNumbers: {
        autoNumber: "AMS"
      }
    }
  });
</script>

<script type="text/x-mathjax-config">
  MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
      for (i = 0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>
<script src="//cdn.jsdelivr.net/npm/mathjax@2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

<style>
.MathJax_Display {
  overflow: auto hidden;
}
</style>

    
  


  

  

  

  

  

  

  

  

  

  

</body>
</html>

<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/clicklove.js"></script>

